﻿using System;
namespace DbFrame.Core.Abstract
{
    using DbFrame;
    using DbFrame.BaseClass;
    using DbFrame.Core.Interface;
    using System.Linq.Expressions;

    public abstract class AbstractQuery<T> : AbstractQueryMappingData<T>, IQuery<T>
    {

        public abstract IQueryJoin<T, TJoin> Join<TJoin>(Expression<Func<T, TJoin, bool>> ON, EJoinType _EJoinType = EJoinType.LEFT_JOIN);

        public abstract IQueryMappingData<TReturn> Select<TReturn>(Expression<Func<T, TReturn>> Select);
        public abstract IQueryMappingData<TReturn> Select<TReturn>(string Select);
        
        public abstract IQuery<T> Where(Expression<Func<T, bool>> Where);

        public abstract IQuery<T> WhereIF(bool IsWhere, Expression<Func<T, bool>> Where);

        public abstract IQuery<T> OrderBy<TReturn>(Expression<Func<T, TReturn>> OrderBy);

        public abstract IQuery<T> OrderByDesc<TReturn>(Expression<Func<T, TReturn>> OrderBy);

        public abstract IQuery<T> GroupBy<TReturn>(Expression<Func<T, TReturn>> GroupBy);

        public abstract IQuery<T> Having(Expression<Func<T, bool>> Where);

        public abstract IQuery<T> SqlString(Action<SQL> _Action);
        //
        IQuery<T> IQuery<T>.Top(int Top)
        {
            this.Top(Top);
            return this;
        }

        IQuery<T> IQuery<T>.Distinct()
        {
            this.Distinct();
            return this;
        }

        IQuery<T> IQuery<T>.TakePage(int PageNumber, int PageSize)
        {
            this.TakePage(PageNumber, PageSize);
            return this;
        }
        //
        public abstract TReturn Max<TReturn>(Expression<Func<T, TReturn>> Max);
        public abstract TReturn Min<TReturn>(Expression<Func<T, TReturn>> Min);
        public abstract TReturn Sum<TReturn>(Expression<Func<T, TReturn>> Sum);

    }
}
